package com.qax.task.cron;

import java.util.concurrent.ScheduledFuture;
/**
 * <BR>Swapper for {@link Task}<BR/>
 *
 * @author leiliang
 */
public class ScheduledTask {

    private final Task task;

    public  volatile ScheduledFuture<?> future;


    public ScheduledTask(Task task) {
        this.task = task;
    }


    public Task getTask() {
        return this.task;
    }

    /**
     * Trigger cancellation of this scheduled task.
     */
    public void cancel() {
        ScheduledFuture<?> future = this.future;
        if (future != null) {
            future.cancel(true);
        }
    }

    @Override
    public String toString() {
        return this.task.toString();
    }

}
